import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTextPane;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JButton;

import model.Tour;

import datencontext.Datencontext;
import display.LoginDisplay;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class Main {

	private JFrame frame;
	private JTextPane txtpnText;
	private JTextPane txtpnText_1;
	private JSpinner spinner;
	private JSpinner spinner_1;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Main window = new Main();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Main() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		
		
		Datencontext datencontext = new Datencontext();
		
		Tour testTour = datencontext.LadeDummyTourdaten();
		
		
		frame = new JFrame();
		frame.getContentPane().setBackground(Color.GRAY);
		frame.setBounds(100, 100, 677, 520);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		txtpnText = new JTextPane();
		txtpnText.setText("Lorem Ipsum und so weiter ist doch eh nur ein Test.");
		txtpnText.setBounds(10, 11, 641, 195);
		frame.getContentPane().add(txtpnText);
		
		txtpnText_1 = new JTextPane();
		txtpnText_1.setEditable(false);
		txtpnText_1.setBounds(10, 217, 641, 187);
		frame.getContentPane().add(txtpnText_1);
		
		JLabel lblSchlssel = new JLabel("Schl\u00FCssel :");
		lblSchlssel.setBounds(10, 415, 64, 14);
		frame.getContentPane().add(lblSchlssel);
		
		JLabel lblTiefe = new JLabel("Tiefe :");
		lblTiefe.setBounds(10, 447, 46, 14);
		frame.getContentPane().add(lblTiefe);
		
		spinner = new JSpinner();
		spinner.setBounds(80, 412, 111, 20);
		spinner.setValue(123456);
		frame.getContentPane().add(spinner);
		
		spinner_1 = new JSpinner();
		spinner_1.setBounds(80, 444, 111, 20);
		spinner_1.setValue(1);
		frame.getContentPane().add(spinner_1);
		
		JButton btnOberenTextVerschlsseln = new JButton("Oberen Text verschl\u00FCsseln");
		btnOberenTextVerschlsseln.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				txtpnText_1.setText(Crypt.encrypt(txtpnText.getText(), (int)spinner.getValue(), (int)spinner_1.getValue()));
			}
		});
		btnOberenTextVerschlsseln.setBounds(461, 415, 190, 23);
		frame.getContentPane().add(btnOberenTextVerschlsseln);
		
		JButton btnNewButton = new JButton("Oberen Text entschl\u00FCsseln");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txtpnText_1.setText(Crypt.decrypt(txtpnText.getText(), (int)spinner.getValue(), (int)spinner_1.getValue()));
			}
		});
		btnNewButton.setBounds(461, 443, 190, 23);
		frame.getContentPane().add(btnNewButton);
	}
}
